package com.hzk.utils;

import java.util.Calendar;

/**
 * @auoter:jackh
 */

public class ageutils {
    public static String evaluate(String sfz) {
        String age;
        Calendar cal = Calendar.getInstance();
        int yearNow = cal.get(Calendar.YEAR);
        int monthNow = cal.get(Calendar.MONTH) + 1;
        int dayNow = cal.get(Calendar.DATE);

        int year = Integer.valueOf(sfz.substring(6, 10));
        int month = Integer.valueOf(sfz.substring(10, 12));
        int day = Integer.valueOf(sfz.substring(12, 14));

        if ((month < monthNow) || (month == monthNow && day <= dayNow)) {
            age = String.valueOf(yearNow - year);
        } else {
            age = String.valueOf(yearNow - year - 1);
        }
        return age;
    }
}
